<?php

namespace Drupal\shusy_team_apply\ViewsController;

use Drupal\shusy_team_apply\ViewsController\handler\field\ShusyTeamApplyEditLinkViewsField;
use Drupal\shusy_team_apply\ViewsController\handler\field\ShusyTeamApplyStatusViewsField;
use Drupal\shusy_team_apply\ViewsController\handler\filter\ShusyTeamApplyStatusViewsFilter;
use EntityDefaultViewsController;


class ShusyTeamApplyViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $revision_table = $this->info['revision table'];

      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => ShusyTeamApplyEditLinkViewsField::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '状态 0 审核中 1 已通过 2 未通过',
        'help' => '状态 0 审核中 1 已通过 2 未通过',
        'real field' => 'status',
        'field' => [
          'handler' => ShusyTeamApplyStatusViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyTeamApplyStatusViewsFilter::class,
        ],
      ];
      $info[$revision_table]['status'] = [
        'title' => '状态 0 审核中 1 已通过 2 未通过',
        'help' => '状态 0 审核中 1 已通过 2 未通过',
        'real field' => 'status',
        'field' => [
          'handler' => ShusyTeamApplyStatusViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyTeamApplyStatusViewsFilter::class,
        ],
      ];

      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }
}
